﻿using System;
using Caliburn.Micro;
using Microsoft.Phone.Tasks;
using Wulong.Phone.Dianping.i18n;

namespace Wulong.Phone.Dianping.ViewModels
{
    public class AboutViewModel : Screen,
        IHandle<MarketplaceReviewTask>,
        IHandle<MarketplaceSearchTask>,
        IHandle<WebBrowserTask>,
        IHandle<EmailComposeTask>
    {
        private IEventAggregator _events;
        public AboutViewModel(IEventAggregator events)
        {
            _events = events;
        }

        public void RateAndReview()
        {
            _events.RequestTask<MarketplaceReviewTask>();
        }

        public void MoreAppsFromUs()
        {
            _events
                .RequestTask<MarketplaceSearchTask>(
                x=>
                    {
                        x.SearchTerms = "Firstep";
                        x.ContentType = MarketplaceContentType.Applications;
                    });
        }

        public void GoToWebsite()
        {
            _events.RequestTask<WebBrowserTask>(
                x=>
                    {
                        x.Uri = new Uri("http://wulongapps.codeplex.com");
                    });
        }

        public void WriteEmail()
        {
            _events.RequestTask<EmailComposeTask>(
                x=>
                    {
                        x.To = "wpcfan@163.com";
                    });
        }

        public void FollowMeOnTwitter()
        {
            _events.RequestTask<WebBrowserTask>(
                x=>
                    {
                        x.Uri = new Uri("http://mobile.twitter.com/wpcfan");
                    });
        }

        public void FollowMeOnWeibo()
        {
            _events.RequestTask<WebBrowserTask>(
                x =>
                {
                    x.Uri = new Uri("http://weibo.com/1903558835");
                });
        }
        
        public void Handle(MarketplaceReviewTask message)
        {

        }

        public void Handle(MarketplaceSearchTask message)
        {
            
        }

        public void Handle(WebBrowserTask message)
        {
            
        }

        public void Handle(EmailComposeTask message)
        {
            
        }
    }
}
